public class Test1 {

    public static void swap(int[] arr, int i, int j) {
        int tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
    }

    // 快速排序
    public static void sort1(int[] arr, int left, int right) {
        int i = left;
        int j = right;
        int key = arr[left];
        while (i < j) {
            while (i < j && arr[i] < key) {
                i++;
            }

            while (i < j && arr[j] > key) {
                j--;
            }

            swap(arr, i, j);
        }
        swap(arr, left, i);

        sort1(arr, left, i);
        sort1(arr, i + 1, right);
    }

    //
    public static void sort2(int[] arr, int left, int right) {

    }

    public static void main(String[] args) {
        int[] arr = {6, 1,2,7,9, 3,4,5,10,8};
        sort1(arr, 0, arr.length - 1);
        for (int x : arr) {
            System.out.print(x + " ");
        }

    }


}
